﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LY.Interface;
using LY.Entity;
using LY.Entity.PageSearch;
using LY.Entity.SearchEntity;
using LY.Entity.Jsons;


namespace QJ.CMS.Areas.Admin.Controllers
{
    public class SiteconfigController : Controller
    {
        //
        // GET: /Admin/Siteconfig/
        private static ISiteconfigService _site;
        public SiteconfigController(ISiteconfigService siteconfig)
        {
            _site = siteconfig;
        }
        //网站配置界面
        public ActionResult SiteconfigEdit()
        {
            S_Siteconfig site =null;
                site = _site.getSiteconfig();
                if (site == null)
                {
                    site = new S_Siteconfig { 
                    Emailport=25,

                    };
                }
                return View(site);
           
        }
        //保存信息
        [HttpPost]
        [ValidateInput(false)]
        public JsonResult SiteconfigSave(S_Siteconfig site, FormCollection collection)
        {
            JsonSMsg rMsg = new JsonSMsg();
            try
            {
                //string errmsg = "";
                long ret = _site.SaveSiteconfig(site);
                if (ret > 0)
                {
                    rMsg.Status = 1;
                    rMsg.Message = "操作成功！";
                }
                else
                {
                    rMsg.Status = -1;
                    rMsg.Message = "意外错误，请稍后重试！";
                }
            }
            catch (Exception ex)
            {
                rMsg.Status = -1;
                rMsg.Message = ex.Message;
            }
            return Json(rMsg);
        }

    }
}
